@import './var.scss';

:global {
    $languages: ts js typescript javascript html css php go sql json bash less scss nginx shell stylus python yaml yml lua;

    .markdown {
        word-break: break-word;
        line-height: 1.75;
        font-weight: 400;
        font-size: 15px;
        overflow-x: hidden;
        letter-spacing: 1.2px;
        color: var(--main-text-color);

        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            line-height: 1.5;
            margin-top: 35px;
            margin-bottom: 10px;
            padding-bottom: 5px;
            color: inherit;
        }

        h1 {
            font-size: 30px;
            margin-bottom: 5px;
        }

        h2 {
            padding-bottom: 12px;
            font-size: 24px;
            border-bottom: 1px solid #ececec;
        }

        h3 {
            font-size: 18px;
            padding-bottom: 0;
        }

        h4 {
            font-size: 16px;
        }

        h5 {
            font-size: 15px;
        }

        h6 {
            margin-top: 5px;
        }

        p {
            line-height: inherit;
            margin-top: 22px;
            margin-bottom: 22px;
        }

        img {
            max-width: 100%;
        }

        hr {
            border: none;
            border-top: 1px solid #ddd;
            margin-top: 32px;
            margin-bottom: 32px;
        }

        a {
            text-decoration: none;
            color: #0269c8;
            border-bottom: 1px solid #d1e9ff;
        }

        a:active,
        a:hover {
            color: #275b8c;
        }

        blockquote {
            color: #666;
            padding: 1px 23px;
            margin: 22px 0;
            border-left: 4px solid #cbcbcb;
            background-color: #f8f8f8;
        }

        blockquote:after {
            display: block;
            content: '';
        }

        blockquote>p {
            margin: 10px 0;
        }

        ul {
            list-style-type: disc;

            ul {
                list-style-type: square;
            }
        }

        ol,
        ul {
            padding-left: 28px;
        }

        ol li,
        ul li {
            margin-bottom: 0;
            list-style: inherit;
        }

        ol ol,
        ol ul,
        ul ol,
        ul ul {
            margin-top: 3px;
        }

        ol li {
            padding-left: 6px;
        }

        .task-list-item {
            list-style: none;
            min-height: 22px;
            padding-left: 24px;
            border: 0;
            margin-left: -24px;

            >input {
                &::before {
                    content: '';
                    position: relative;
                    top: 0;
                    left: 0;
                    display: block;
                    width: 16px;
                    height: 16px;
                    border: 1px solid #d9d9d9;
                    border-radius: 2px;
                    background-color: #fff;
                    transition: all 0.3s;
                    border-collapse: separate;
                }

                &:checked::before {
                    background-color: var(--primary-color);
                    border-color: var(--primary-color);
                }

                &::after {
                    content: ' ';
                    position: absolute;
                    left: 6.571429px;
                    top: 6.142857px;
                    display: table;
                    width: 5.71428571px;
                    height: 9.14285714px;
                    border: 2px solid #fff;
                    border-top: 0;
                    border-left: 0;
                    transition: all 0.1s cubic-bezier(0.71, -0.46, 0.88, 0.6), opacity 0.1s;
                    transform: rotate(45deg) scale(0);
                    opacity: 0;
                }

                &:checked::after {
                    opacity: 1;
                    transform: rotate(45deg) scale(1);
                }
            }
        }

        code,
        pre {
            font-family: Menlo, Monaco, Consolas, Courier New, monospace;
        }

        code {
            display: inline;
            padding: 2px 4px;
            border-radius: 4px;
            margin: 0 2px;
            color: var(--main-text-color);
            background-color: rgba(27, 31, 35, 0.05);
            font-size: 14px;
            word-wrap: break-word;
            word-break: break-all;
        }

        pre {
            position: relative;
            max-height: 400px;
            padding-top: 30px;
            border-radius: 5px;
            margin: 10px 0;
            background-color: var(--bg-code);
            font-size: 1em;

            &::before {
                position: absolute;
                top: 0;
                display: block;
                width: 100%;
                height: 30px;
                background-image: url(https://wipi.oss-cn-shanghai.aliyuncs.com/2020-07-12/97e4eed2-a992-4976-acf0-ccb6fb34d308.png);
                background-position: 10px 10px;
                background-size: 40px;
                background-repeat: no-repeat;
                background-color: var(--bg-code);
                content: '';
            }

            code {
                display: block;
                max-height: 370px;
                padding: 12px 10px;
                padding-top: 9px;
                border-radius: 0;
                color: var(--main-text-color);
                background-color: var(--bg-code);
                overflow: auto;
                overscroll-behavior: contain;
                font-size: 12px;
                margin: 0;
                white-space: pre-wrap;

                @at-root pre {
                    overflow: hidden;
                }
            }
        }

        blockquote {
            padding: 1px 23px;
            border: 1px solid var(--border-color);
            border-left: 4px solid #cbcbcb;
            border-left: 4px solid var(--disable-text-color);
            margin: 22px 0;
            color: #666666;
            background-color: var(--bg-second);
        }

        strong {
            font-weight: bold;
        }

        strong::before {
            content: '「';
        }

        strong::after {
            content: '」';
        }

        p em {
            font-weight: normal;
        }

        em {
            color: var(--main-text-color);
            font-style: normal;
        }

        em strong {
            color: var(--main-text-color);
        }

        img {
            display: block;
            display: block;
            width: 100%;
            border-radius: var(--border-radius);
            margin: 20px auto;
            object-fit: contain;
        }

        table {
            display: inline-block;
            font-size: 13px;
            width: auto;
            max-width: 100%;
            overflow: auto;
            border: 1px solid var(--border-color);
            border-collapse: collapse;

            thead {
                background-color: var(--bg-code);
            }

            tr:nth-child(2n) {
                background-color: var(--bg-code);
            }

            th,
            td {
                padding: 4px 8px;
                line-height: 24px;
            }
        }

        @each $language in $languages {
            code.language-#{$language}::before {
                content: '#{$language}';
                position: absolute;
                top: 8px;
                right: 45px;
                font-size: 12px;
                line-height: 1;
                cursor: pointer;
                color: hsla(0, 0%, 54.9%, 0.8);
                transition: color 0.1s;
            }
        }
    }
}